package com.yazi.mxz.common.db.dao.impl;


import java.util.HashMap;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.yazi.mxz.common.db.dao.StoreRestockGoodsDao;
import com.yazi.mxz.common.entity.beans.StoreRestock;
import com.yazi.mxz.common.entity.beans.StoreRestockGoods;

import com.myframework.smhj.hibernate.dao.BasicDao;

@Repository("storeRestockGoodsDao")
public class StoreRestockGoodsDaoImpl extends BasicDao<StoreRestockGoods> implements StoreRestockGoodsDao {


	public StoreRestockGoodsDaoImpl() {
		super(StoreRestockGoods.class);
	}

	@Override
	public Criteria getExample(StoreRestockGoods srg, String searchWord) {
		Criteria c = super.getExample(srg, searchWord);
		if (null != srg) {
			StoreRestock  sr = srg.getStoreRestock();
			if (null != sr) {
				if (null != sr.getRestockId()) {
					c.add(Restrictions.eq("storeRestock.restockId", sr.getRestockId()));
				} else {
					// ...other StoreRestock's fields search
				}
			}
			// ...other StoreRestockGoods's fields search
		}
		// ...searchWord search
		return c;
	}

	@Override
	public int deleteByRestockId(Long restockId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("restockId", restockId);
		return executeUpdate("delByRestockIdHql", map);
	}

}
